
import string
import re

data = open('data.csv','r').read()
data_l = string.split(data,'\n')
tests = open('tests.csv','r').read()
tests_l = string.split(tests,'\n')

#print data_l,tests_l

def __do(tests_l, data_l, cold_s):
    out_s = ""
    lino_n = 0
    for r in data_l:
        lino_n += 1
        cols_l = string.split(r, cold_s)
        if lino_n == 1:
            out_s += tests_l[0] + cold_s + r + '\n'
        else:
            if cols_l[0] in tests_l[1:]:
                out_s += '1' + cold_s + r + '\n'
            else:
                out_s += cold_s + r + '\n'
    return out_s

print __do(tests_l, data_l, '|')

